import mongoose from "mongoose";

const majorSchema = new mongoose.Schema({
  id: String, // id
  school_id: String, // 学校id
  special_id: String, // 专业id
  nation_feature: String, // 国家特色专业
  province_feature: String, // 省份特色专业
  is_important: String, // 是否为重要专业
  limit_year: String, // 限制年份
  year: String, // 年份
  level3_weight: String, // 三级权重
  nation_first_class: String, // 国家一级学科
  is_video: Number, 
  special_name: String, // 专业名称
  special_type: String, // 专业类型
  type_name: String, // 类型名称
  level3_name: String, // 三级名称
  level3_code: String, // 三级代码
  level2_name: String, // 二级名称
  level2_id: String, // 二级id
  level2_code: String, // 二级代码
  code: String, // 代码
});

const schoolSchema = new mongoose.Schema({
  name: String,
  children: [majorSchema],
});

// 添加复合索引
schoolSchema.index({ name: 1 });
schoolSchema.index({ "children.special_id": 1 });
schoolSchema.index({ "children.level2_name": 1 });
schoolSchema.index({ "children.special_name": 1 });

export const School = mongoose.model("School", schoolSchema);
